feat: add comprehensive weight unit conversion module#1012
Merged
siriak merged 2 commits intoTheAlgorithms:masterfrom Jan 31, 2026
Merged
feat: add comprehensive weight unit conversion module#1012siriak merged 2 commits intoTheAlgorithms:masterfrom
siriak merged 2 commits intoTheAlgorithms:masterfrom
Conversation
Contributor
Author
|
@siriak, this is ready to be merged. |
Contributor
Author
|
clippy warnings are a CI issue. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1012 +/- ##
==========================================
+ Coverage 96.09% 96.16% +0.06%
==========================================
Files 378 379 +1
Lines 27594 28036 +442
==========================================
+ Hits 26517 26961 +444
+ Misses 1077 1075 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Could you solve the clippy warnings in a separate PR so that this one merges cleanly? |
Contributor
Author
This is a new problem for the entire module. The only way to fix it is to update |
Member
|
You can just disable it in Cargo.toml |
siriak
approved these changes
Jan 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new weight conversion module to the conversions directory, providing support for 23 different weight units across metric, imperial, troy, and scientific measurement systems.
What's New
Units Added (23 Total)
Large Metric Units:
Standard Metric Units:
Imperial/US Large Units:
Imperial/US Common Units:
Troy Weight System:
Other Units:
Features
✅ Type-safe conversions using Rust enums
✅ String-based conversions for convenience
✅ Flexible API supporting both
WeightUnitenums and string identifiers✅ Comprehensive aliases (e.g., "kg", "lb", "oz", "μg", "ozt")
✅ Extensive test coverage with 100+ test cases
✅ Full documentation with usage examples and references
✅ Zero dependencies beyond std library
✅ High precision conversions based on official standards
Usage Examples
Type-Safe Conversion
String-Based Conversion
Mixed Usage
Testing
All tests pass with comprehensive coverage:
cargo test weightTest Coverage:
Implementation Details
The module follows the same pattern as the existing
pressure.rsmodule:IntoWeightUnittrait for polymorphismReferences
All conversion factors are sourced from official references:
Checklist
cargo fmtsrc/conversions/mod.rs